package com.estar.assistsurvy.database;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class myDBTools {

	private myDatabaseHelper myHelper;
	private SQLiteDatabase readDB,writeDB;
	private Cursor cursor;

	public myDBTools(Context context) {
		myHelper=new myDatabaseHelper(context);
	}
	
	public void writeDB(String sql,Object[] bindArgs){
		
		writeDB=myHelper.getWritableDatabase();
		writeDB.execSQL(sql, bindArgs);
		
	}
	
	public Cursor readDB(String sql,String[] bindArgs){
		
		readDB=myHelper.getReadableDatabase();
		cursor=readDB.rawQuery(sql, bindArgs);
		return cursor;
		
	}
	
	public void DBclose(){
		if(writeDB != null){
			writeDB.close();
		}
		if(readDB != null){
			readDB.close();
		}
		if(cursor != null){
			cursor.close();
		}
	}
	
}